package com.ev.k3cloudBusiness.service.impl;

import com.alibaba.fastjson.JSON;
import com.ev.k3cloud.entity.K3CloudBillSaveBaseEntity;
import com.ev.k3cloud.entity.K3CloudTopEntity;
import com.ev.k3cloud.enums.K3CloudBillFormId;
import com.ev.k3cloud.service.K3CloudService;
import com.ev.k3cloudBusiness.service.K3OthInStockService;
import com.ev.k3cloudBusiness.service.K3OthOutStockService;
import com.ev.k3cloudBusiness.vo.K3OthInStockInsertVo;
import com.ev.k3cloudBusiness.vo.K3OthOutStockInsertVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class K3OthInStockServiceImpl implements K3OthInStockService {

    @Autowired
    K3CloudService k3CloudService;

    @Override
    public String insert(K3OthInStockInsertVo param) {
        K3CloudBillSaveBaseEntity saveBaseEntity = new K3CloudBillSaveBaseEntity();
        saveBaseEntity.setModel(param);
        //开启自动提交和审核
        saveBaseEntity.setIsAutoSubmitAndAudit(true);
        K3CloudTopEntity topEntity = new K3CloudTopEntity();
        topEntity.setFormid(K3CloudBillFormId.STK_STOCK_IN.getFormId());
        topEntity.setData(saveBaseEntity);
        return k3CloudService.save(JSON.toJSONString(topEntity));
    }
}
